<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Users extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table  =  $this->table('users');
        $table->addColumn('user_name', 'string',array('limit'  =>  50,'default'=>'','comment'=>'系统用户名'))
            ->addColumn('pid', 'integer',array('limit'  =>  11,'default'=>0,'comment'=>'上级ID'))
            ->addColumn('nick_name', 'string',array('limit'  =>  50,'default'=>'','comment'=>'用户昵称'))
            ->addColumn('real_name', 'string',array('limit'  =>  50,'default'=>'','comment'=>'真实姓名'))
            ->addColumn('union_id', 'string',array('limit'  =>  255,'default'=>'','comment'=>'微信唯一id'))
            ->addColumn('open_id', 'string',array('limit'  =>  255,'default'=>'','comment'=>'open_id'))
            ->addColumn('avatar_url', 'string',array('limit'  =>  255,'default'=>'','comment'=>'头像地址'))
            ->addColumn('phone', 'string',array('limit'  =>  50,'default'=>'','comment'=>'手机号'))
            ->addColumn('status', 'integer',array('limit'  =>  1,'default'=>1,'comment'=>'状态1正常  2冻结'))
            ->addColumn('last_login_ip', 'biginteger',array('default'=>null,'comment'=>'最近一次登录IP'))
            ->addColumn('last_login_time', 'datetime',array('default'=>null,'comment'=>'最近一次登录时间'))
            ->addColumn('create_time', 'datetime',array('default'=>null,'comment'=>'创建时间'))
            ->addColumn('update_time', 'datetime',array('default'=>null,'comment'=>'更新时间'))
            ->addColumn('delete_time', 'datetime',array('default'=>null,'comment'=>'删除时间'))
            ->addIndex('pid')
            ->create();
    }
}
